package org.simplesocket.simplenettymtbatis.config;

import lombok.Data;

@Data
public class ConnectionPoolConfig {
    
    private int poolInitSize = 5;
    
    private int poolMinSize = 5;
    
    private int poolMaxSize = 5;
    
    private long poolMaxWait = 60000;
    
    private long poolCheckTimeInterval = 60000;
    
    private long poolMinFreeTime = 1800000;
    
    private long poolMaxFreeTime = 3600000;
    
    private boolean poolKeepAlive = true;
    
    private ConnectionPoolConfig() {}
    
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder{
        
        private ConnectionPoolConfig config;
        
        private Builder() {
            config = new ConnectionPoolConfig();
        }
        
        
        public Builder poolMinSize(int size){
            this.config.setPoolMinSize(size);
            return this;
        }
        
        public Builder poolMaxSize(int size){
            this.config.setPoolMaxSize(size);
            return this;
        }
        
        public Builder poolMaxWait(long millisecond){
            this.config.setPoolMaxWait(millisecond);
            return this;
        }
        
        public Builder poolCheckTimeInterval(long millisecond){
            this.config.setPoolCheckTimeInterval(millisecond);
            return this;
        }
        
        public Builder poolMinFreeTime(long millisecond){
            this.config.setPoolMinFreeTime(millisecond);
            return this;
        }
        
        public Builder poolMaxFreeTime(long millisecond){
            this.config.setPoolMaxFreeTime(millisecond);
            return this;
        }
        
        public Builder poolKeepAlive(boolean alive){
            this.config.setPoolKeepAlive(alive);
            return this;
        }
        
        public ConnectionPoolConfig build(){
            return config;
        }
    }
    
}
